package com.chcit.share.admin.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.chcit.share.admin.core.http.HttpResult;
import com.chcit.share.admin.core.page.PageRequest;

import com.chcit.share.admin.model.SysUser;
import com.chcit.share.admin.service.SysUserService;

/**
 * ---------------------------
 * 用户 (SysUserController)         
 * ---------------------------
 * 作者：  share-generator
 * 时间：  2019-04-05 01:48:05
 * 说明：  我是由代码生成器生生成的
 * ---------------------------
 */

@Api(value = "用户控制器")
@RestController
@RequestMapping("user")
public class SysUserController {

	@Autowired
	private SysUserService sysUserService;

	/**
	 * 保存用户
	 * @param record
	 * @return
	 */
	@ApiImplicitParams({

	})
	@ApiOperation(value = "新增或修改", notes = "传入User", position = 1)
	@PostMapping(value="/save")
	public HttpResult save(@RequestBody SysUser record) {
		return HttpResult.ok(sysUserService.save(record));
	}

    /**
     * 删除用户
     * @param records
     * @return
     */
	@PostMapping(value="/delete")
	public HttpResult delete(@RequestBody List<SysUser> records) {
		return HttpResult.ok(sysUserService.delete(records));
	}

    /**
     * 基础分页查询
     * @param pageRequest
     * @return
     */    
	@PostMapping(value="/findPage")
	public HttpResult findPage(@RequestBody PageRequest pageRequest) {
		return HttpResult.ok(sysUserService.findPage(pageRequest));
	}
	
    /**
     * 根据主键查询
     * @param id
     * @return
     */
    @ApiOperation(value="获取用户信息",notes ="根据用户ID获取用户信息")
    @ApiImplicitParam(name ="userId",value="用户ID",required = true, dataType = "Long")
	@GetMapping(value="/findById")
	public HttpResult findById(@RequestParam Long id) {
		return HttpResult.ok(sysUserService.findById(id));
	}
}
